<?php

namespace Modules\Car\Http\Controllers\Api;

use App\Events\NotifyEvent;
use App\Helpers\NewBaseData;
use App\Helpers\PayTrait;
use App\Helpers\ResponseData;
use App\Models\Car;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\DB;
use Modules\Car\Entities\CarOrder;
use Modules\Car\Entities\RecognizeDrivingLicense;
use Modules\Car\Http\Requests\Order\OrderRequest;

//待送车订单
class CollectCarController extends Controller
{
    use ResponseData,PayTrait,NewBaseData;

    public function list(CarOrder $model,Request $request){
        $user = $request->user();
        $size = $request->input('size',10);
        $model = $this->searchOrderModel($request);
        $model = $model->where('status',6)->where('process_status',3);
        if($user->post_id==2){
            $model = $model->where('department',$user->department_id);
        }else{
            if($request->filled('department')){
                $model = $model->where('department',$request->department);
            }
        }
        // 待结算列表排序，最新的订单排最后，历史待结算的订单排第一；未结清列表排序，一样。
        //  $data = $model->orderByDesc('return_time')->paginate($size);
       $data = $model->orderBy('id', 'asc')->paginate($size);
        return $this->success($data);
    }
}
